<template>
  <div>
    <el-table
      :data="List"
      border
      style="width: 100%">
      <el-table-column
        prop="glist[0].name"
        label="商品名称"
        width="180">
      </el-table-column>
      <el-table-column
        prop="glist[0].num"
        label="交易数量"
        width="180">
      </el-table-column>
      <el-table-column
        prop="info.bname"
        label="买家姓名"
        width="180">
      </el-table-column>
      <el-table-column
        prop="seller.nickname"
        label="卖家昵称"
        width="180">
      </el-table-column>
      <el-table-column
      :formatter="formatterType2"
        prop="info.otype"
        label="订单类型"
        width="180">
      </el-table-column>
      <el-table-column
      :formatter="formatterType"
        prop="info.ostate"
        label="交易情况"
        width="180">
      </el-table-column>
      <el-table-column
        prop="info.stime"
        label="订单开始时间">
      </el-table-column>
      <el-table-column
        prop="info.etime"
        label="交易完成时间">
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
export default {
    name:'OrderList',
    data(){
        return{
            orderList:[       
            ],
        }
    },
    methods:{
        getOrderList(){
            if(this.$route.query.gid){ 
            const gid = this.$route.query.gid;
            this.$axios.get("/api/getOrderByGid",{
              params:{
                  gid:gid
              }}).then(res =>{
                console.log(res.data)
                this.orderList=res.data.data;
              }).catch(error =>{
               // console.log('提交失败')
                console.log(error )
              })
            }
        },
        getOrderList2(){
            if(this.$route.query.phone){ 
            const phone = this.$route.query.phone;
            this.$axios.get("/api/getOrderByPhone",{
              params:{
                phone:phone
              }}).then(res =>{
                console.log(res.data)
                this.orderList=res.data.data;
              }).catch(error =>{
               // console.log('提交失败')
                console.log(error )
              })
            }
        },
        formatterType(row){
          switch(row.info.ostate){
            case 0:
              return '客户下单'
            case 1:
              return '交易完成'
            case 2:
              return '商家确认'
            case 3:
              return '备货完成'
            case 4:
              return '开始发货'
            case -1:
              return '取消订单'
            default:
              return ''
          }
      },
      formatterType2(row){
          switch(row.info.otype){
            case 0:
              return '购买'
            case 1:
              return '租借'
            default:
              return ''
          }
        },
    },
    computed:{
        List(){
        const  lt= JSON.parse(JSON.stringify(this.orderList));
        console.log(lt)
        return lt
      }
    },
    mounted(){
        this.getOrderList()
        this.getOrderList2()
    }
}
</script>
<style>

</style>
